package com.kvest.fortests.activity;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.widget.DrawerLayout;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import com.kvest.fortests.R;

/**
 * Created with IntelliJ IDEA.
 * User: Kvest
 * Date: 23.08.13
 * Time: 19:59
 * To change this template use File | Settings | File Templates.
 */
public class NavigationDrawerActivity extends Activity implements DrawerLayout.DrawerListener {
    private DrawerLayout mDrawerLayout;
    private ListView mDrawerList;

    @Override
    public void onCreate(Bundle savedState) {
        super.onCreate(savedState);
        setContentView(R.layout.navigation_drawer_usage);

        mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
        mDrawerList = (ListView) findViewById(R.id.left_drawer);

        // Set the adapter for the list view
        mDrawerList.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, new String[]{"Item1", "Item2", "Item3", "Item4"}));
        mDrawerList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                mDrawerLayout.closeDrawer(Gravity.LEFT);
            }
        });

        mDrawerLayout.setDrawerListener(this);

        findViewById(R.id.open).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mDrawerLayout.openDrawer(Gravity.LEFT);
            }
        });
        findViewById(R.id.close).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mDrawerLayout.closeDrawers();
                //mDrawerLayout.closeDrawer(Gravity.LEFT);
            }
        });
    }

    @Override
    public void onDrawerOpened(View view) {
        Log.d("KVEST_TAG", "opened");
    }

    @Override
    public void onDrawerClosed(View view) {
        Log.d("KVEST_TAG", "closed");
    }

    @Override
    public void onDrawerStateChanged(int satet) {}

    @Override
    public void onDrawerSlide(View view, float v) {}
}
